import {createChunk} from './utils/createChunk';

onmessage = async (e) => {
  const { chunkSize, endIndex, startIndex, file } = e.data;
  const proms = [];
  for (let i = startIndex; i < endIndex; i++) {
    const chunk = createChunk(file, i, chunkSize);
    proms.push(chunk);
  }
  const chunks = await Promise.all(proms);
  postMessage(chunks);
};
